using System;
using System.Reflection;
using ASPEMAILLib;

/// <summary>
/// Summary description for SendEmail
/// </summary>
public class SendEmail
{
    public SendEmail()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public bool Send(string eFrom, string eFromName, string eTo, string eSubject, string eBody, string eHost)
    {
        bool bResult = true;
        ASPEMAILLib.IMailSender objMail;
        objMail = new ASPEMAILLib.MailSender();

        objMail.Host = eHost;

        objMail.From = eFrom;		// From address
        objMail.FromName = eFromName;	// optional

        // To address, 2nd argument optional
        objMail.AddAddress(eTo, Missing.Value);

        // message subject
        objMail.Subject = eSubject;

        // message body
        objMail.Body = eBody;
        objMail.IsHTML = 1;

        try
        {
            objMail.CharSet = "UTF-8";
            objMail.ContentTransferEncoding = "Quoted-Printable";
            objMail.Send(Missing.Value);
            bResult = true;
        }
        catch (Exception e)
        {
            string s = e.Message.ToString();
            bResult = false;
        }

        return bResult;
    }

    public bool Send(string eFrom, string eTo, string eSubject, string eBody, string eHost)
    {
        bool bResult = true;
        ASPEMAILLib.IMailSender objMail;
        objMail = new ASPEMAILLib.MailSender();

        objMail.Host = eHost;

        objMail.From = eFrom;		// From address

        // To address, 2nd argument optional
        objMail.AddAddress(eTo, Missing.Value);

        // message subject
        objMail.Subject = eSubject;

        // message body
        objMail.Body = eBody;
        objMail.IsHTML = 1;

        try
        {
            objMail.CharSet = "UTF-8";
            objMail.ContentTransferEncoding = "Quoted-Printable";
            objMail.Send(Missing.Value);
            bResult = true;
        }
        catch (Exception e)
        {
            string s = e.Message.ToString();
            bResult = false;
        }

        return bResult;
    }
}
